1 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Category]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
\r
2 drop table [dbo].[Category]
\r
5 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Product]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
\r
6 drop table [dbo].[Product]
\r
9 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[User]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
\r
10 drop table [dbo].[User]
\r
13 CREATE TABLE [dbo].[Category] (
\r
14 [id] [int] IDENTITY (1, 1) NOT NULL ,
\r
15 [name] [varchar] (25) NOT NULL ,
\r
16 [parent_category_id] [int] NULL
\r
20 CREATE TABLE [dbo].[Product] (
\r
21 [id] [int] IDENTITY (1, 1) NOT NULL ,
\r
22 [name] [varchar] (50) NOT NULL ,
\r
23 [description] [varchar] (1000) NULL ,
\r
24 [pictureFile] [varchar] (50) NULL ,
\r
25 [price] [money] NULL ,
\r
26 [category_id] [int] NOT NULL
\r
30 CREATE TABLE [dbo].[User] (
\r
31 [id] [int] IDENTITY (1, 1) NOT NULL ,
\r
32 [login] [varchar] (15) NULL ,
\r
33 [password] [varchar] (12) NULL ,
\r
34 [name] [varchar] (30) NULL ,
\r
35 [email] [varchar] (50) NULL ,
\r
36 [type] [varchar] (8) NOT NULL ,
\r
37 [address] [varchar] (50) NULL ,
\r
38 [city] [varchar] (15) NULL ,
\r
39 [country] [varchar] (15) NULL ,
\r
40 [zipcode] [varchar] (8) NULL ,
\r
41 [lastAccess] [smalldatetime] NULL
\r
45 ALTER TABLE [dbo].[Category] WITH NOCHECK ADD
\r
46 CONSTRAINT [PK_Category] PRIMARY KEY CLUSTERED
\r
52 ALTER TABLE [dbo].[Product] WITH NOCHECK ADD
\r
53 CONSTRAINT [PK_Product] PRIMARY KEY CLUSTERED
\r
59 ALTER TABLE [dbo].[User] WITH NOCHECK ADD
\r
60 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED
\r
66 ALTER TABLE [dbo].[User] ADD
\r
67 CONSTRAINT [IX_User] UNIQUE NONCLUSTERED
\r